Page({

    /**
     * 页面的初始数据
     */
    data: {
      imgs: [
        "../../image/goods01.jpg",
        "../../image/goods02.jpg",
        "../../image/goods03.jpg",
        "../../image/goods04.jpg"
      ],
      num:90,
      goodsReverse:[],
      hiddenName:true,
      boolen:false,
      eachBoolen:false,
      
      iconArr: [{
          icon_picture: "../../image/icon-fujin.png",
          icon_name: "耳机",
          url:"/pages/fujin/fujin"
        },
        {
          icon_picture: "../../image/icon-fuli.png",
          icon_name: "福利",
          url:"/pages/fuli/fuli"
        },
        // {
        //   icon_picture: "../../image/icon-muma.png",
        //   icon_name: "签到",
  
        // },
        {
          icon_picture: "../../image/icon-qiandao.png",
          icon_name: "周边",
          url:"/pages/zhoubian/zhoubian"
        },
        {
          icon_picture: "../../image/icon-qinzi.png",
          icon_name: "亲子",
          url:"/pages/qingzi/qingzi"
        },
        {
          icon_picture: "../../image/icon-tiyu.png",
          icon_name: "体育",
          url:"/pages/tiyu/tiyu"
        },
        {
          icon_picture: "../../image/icon-xingxing.png",
          icon_name: "信息",
          url:"/pages/xinxi/xinxi"
        },
        {
          icon_picture: "../../image/icon-zhanhui.png",
          icon_name: "展会",
          url:"/pages/zhanhui/zhanhui"
        },
      ],
      goodsArr: [
      ],
      imgUrls: [
        '../../image/slide-1.jpg',
        '../../image/slide-2.jpg',
        '../../image/slide-3.jpg',
        '../../image/slide-4.jpg',
        '../../image/slide-5.jpg',
      ],
      indicatorDots: true, //是否显示面板指示点
      autoplay: true, //是否自动播放
      interval: 3000, //停留时间间隔
      duration: 1000, //播放时长
      previousMargin: '50px', //前边距，可用于露出前一项的一小部分，接受 px 和 rpx 值
      nextMargin: '50px', //后边距，可用于露出后一项的一小部分，接受 px 和 rpx 值
      circular: true, //是否采用衔接滑动
      currentSwiperIndex: 0, //swiper当前索引
    
  
  
  
    },
    
  // }),
  dianji(){
    this.setData({
      boolen:!this.data.boolen,
    })
    console.log(this.data.boolen);
    if(this.data.boolen){
      this.setData({
        goodsReverse:this.data.goodsArr.reverse(),
      })}else{
        this.setData({
          goodsArr:this.data.goodsArr.reverse()
        })
      }
    },
  
  swiperBindchange(e) {
    this.setData({
      currentSwiperIndex: e.detail.current
    })
  },
  clickMe:function(e){
    this.setData({
        hiddenName:!this.data.hiddenName
    })
  },
    onLoad: function (options) {
      this.getGoodsData();
      this. getGoodsBanner();
    },
    getGoodsData() {
      let _this = this;
      _this.setData({
        num:_this.data.num+1,
      })
      // index:this.data.num,
      let pagenum=this.data.num;
      let cid=5;
      let pagesize=20;
  
     
     
       
      wx.request({
        
        url: 'https://api-hmugo-web.itheima.net/api/public/v1/goods/search?"cid"=600&pagenum=1604&pagesize=20', //仅为示例，并非真实的接口地址
          
        header: {
          'content-type': 'application/json' // 默认值
        },
        // data:{
        //   "cid":cid,
        //   pagenum:pagenum,
        //   pagesize:pagesize,
        // } , 
        success(res) {
          let goodslist = res.data.message.goods;
          let lists = [];
          goodslist.forEach(item => {
            let {
              goods_id,
              goods_name,
              goods_small_logo,
              goods_price
            } = item;
            let data = {
              id: goods_id,
              goods: goods_small_logo,
              name: goods_name,
              price: goods_price
  
            }
            if (goods_small_logo) {
              lists.push(data);
            }
          })
          _this.setData({
            goodsArr: lists
  
          })
  
        }
      })
    },
    qiandao(options){
      
      if(options.currentTarget.dataset.id==2){
        console.log(123);
        this.setData({
          eachBoolen:!this.data.eachBoolen,
        })
      }
  
    },
    getGoodsBanner(){
        let _this=this;
        wx.request({
          url:"https://api-hmugo-web.itheima.net/api/public/v1/home/swiperdata",
          header:{
            "content-type":"application/json"
          },
          success(res){
            let goodsBanner=res.data.message;
            console.log(goodsBanner)
              let lists=[];
            goodsBanner.forEach(item=>{
              let {image_src}=item;
  
              lists.push(image_src);
            })
            _this.setData({
              imgs:lists,
            })
  
  
          }
        })
    },
  
    /**
     * 生命周期函数--监听页面初次渲染完成
     */
    onReady: function () {
  
    },
  
    /**
     * 生命周期函数--监听页面显示
     */
    onShow: function () {
      this.getGoodsData();
    },
  
    /**
     * 生命周期函数--监听页面隐藏
     */
    onHide: function () {
  
    },
  
    /**
     * 生命周期函数--监听页面卸载
     */
    onUnload: function () {
  
    },
  
    /**
     * 页面相关事件处理函数--监听用户下拉动作
     */
    onPullDownRefresh: function () {
  
    },
  
    /**
     * 页面上拉触底事件的处理函数
     */
    onReachBottom: function () {
  
    },
  
    /**
     * 用户点击右上角分享
     */
    onShareAppMessage: function () {
  
    }
  })